import path from 'path'
const __dirname = path.resolve()

const todoIndex = {
    path: '/api/todo/all/cors',
    method: 'get',
    func: (request, response) => {
        let data = {
            code: 404,
        }
        setTimeout(() => {
            let s = JSON.stringify(data)
            response.send(s)
        }, 500)
    }
}

const todoData = {
    path: '/api/todo/all/data',
    method: 'post',
    func: (request, response) => {
        // let data = {
        //     code: 404,
        // }
        // let s = JSON.stringify(data)
        response.status(500).send('Something broke!');
        // response.send(s)
    }
}

const socketIndex = {
    path: '/',
    method: 'get',
    func: (request, response) => {
        console.log('socket page')
        let path1 = 'template/socket/index.html'
        let path2 = 'index.html'
        response.sendFile(path.join(__dirname, path2))
    }
}

export const indexRoutes = [
    socketIndex,
    todoIndex,
    todoData,
]

